import { Module } from '@nestjs/common';
import { ChargeOrderMsgService } from './charge-order-msg.service';
import { ConfigureModule, ConfigureService } from '@app/configure';
import { CacheModule } from '@app/cache';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ChargeOrder } from '@app/db/entities/ChargeOrder';
import { AliIotModule } from 'apps/ali-iot/src/ali-iot.module';
import { Device } from '@app/db/entities/Device';
import { User } from '@app/db/entities/User';
import { UserWalletLog } from '@app/db/entities/UserWalletLog';
import { Merchant } from '@app/db/entities/Merchant';
import { MerchantDailyIncome } from '@app/db/entities/MerchantDailyIncome';
import { PayModule } from './pay/pay.module';
import { Platform } from '@app/db/entities/Platform';
import { PlatformDailyIncome } from '@app/db/entities/PlatformDailyIncome';
import { PrivateChargeModule } from './private-charge/private-charge.module';
import { ChargingStation } from '@app/db/entities/ChargingStation';
import { ChargingStationDailyIncome } from '@app/db/entities/ChargingStationDailyIncome';
import { ChargeCardOrderModule } from './charge-card-order/charge-card-order.module';
import { UtilsModule } from '@app/utils';

@Module({
  imports: [
    UtilsModule,
    ConfigureModule,
    CacheModule,
    AliIotModule,

    TypeOrmModule.forRootAsync({
      name : 'common',
      imports : [ConfigureModule],
      inject : [ConfigureService],
      useFactory : (config:ConfigureService) => {
        return {
          ...config.get('database.common'),
          
          poolSize : 1,
          //minSize : 1
        }
      }
    }),

    TypeOrmModule.forRootAsync({
      imports : [ConfigureModule],
      inject : [ConfigureService],
      useFactory : (config:ConfigureService) => {
        return {
          ...config.get('database.default'),
          
          poolSize : 2,
          //minSize : 1
        }
      }
    }),

    TypeOrmModule.forFeature([Device, ChargeOrder, User, UserWalletLog, Merchant, MerchantDailyIncome, Platform, PlatformDailyIncome, ChargingStation, ChargingStationDailyIncome]),
    PayModule,
    PrivateChargeModule,
    ChargeCardOrderModule
  ],
  providers: [ChargeOrderMsgService],
})
export class ChargeOrderMsgModule {}
